[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
DECLARE

Purpose

    To create one or more memory variable arrays.

Syntax

    DECLARE <array name> [<exp N>] [,<array list>]

Arguments

    <array> is the name of an array to create.  Note that you can create
    more than one array with a single DECLARE statement.

    <expN> is the number of elements in the array up to a maximum of 4096.
    An array DECLAREd with less than one element defaults to one; more than
    4096 elements defaults to 4096.

    Note: The square brackets surrounding <expN> are a required part of
    the command syntax and in this case do not signify an optional
    argument.

Usage

    DECLARE creates single dimensional private arrays whose scope is the
    current procedure.  At the same time, PUBLIC and private arrays created
    in higher-level procedures with the same name are hidden.  An array
    uses one memory variable slot of the allotted memory variables.

    Unlike memory variables, arrays and array elements cannot be saved in
    (.mem) files.

    To assign a value to an array element, use the assignment operator (=)
    or the STORE command.  To STORE a value to an entire array, use
    AFILL().  To retrieve a value from an array, refer to the element using
    a subscript indicating its position in the array.

    To determine the number of elements in an array, use LEN() by
    specifying only the array name as the function argument.

    The LEN() function may be used to return the number of elements in an
    array, if the array name is the only parameter specified in the
    function.

    Data types: Elements within the same array can be mixed type and
    obey all the typing rules of ordinary memory variables.  The TYPE()
    function returns an "A" for an array reference and the data type of an
    element if the reference includes the subscript.

    Use within macro variables: References to arrays and array elements
    can be made with macro variables with one exception: the brackets
    cannot be in a macro variable when DECLAREing the array.  Note,
    however, that you cannot use or expand an array element as a macro
    variable.  If you wish to use an array element in a macro, assign the
    contents of the array element to a memory variable and then use the
    memory variable as the macro variable.  For example:

    DECLARE fields[FLDCOUNT()]
    AFIELDS(fields)           
    fld_name = fields[1]      
    ? &fld_name               

    Passing parameters: Array and array elements can be passed as
    parameters to Clipper procedures, user_defined functions, and external
    procedures that use the Extend System.  Arrays are passed by reference
    and array elements are passed by value.  You cannot, however, pass
    entire arrays to external procedures using the CALL command.  In this
    case, you can only pass array elements one at a time.

    PUBLIC arrays: To create PUBLIC arrays, use the PUBLIC statement.
    Note that PUBLIC arrays follow all the same rules as private arrays
    with the exception of the scope which is all procedures.  See PUBLIC
    for more information.

See Also: PUBLIC
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson